package com.sam.dynamic.project.ds0.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sam.dynamic.project.ds0.mapper.MessageMapper;
import com.sam.dynamic.project.ds0.model.entity.Message;
import com.sam.dynamic.project.ds0.service.MessageService;
import com.sam.dynamic.project.ds1.model.entity.Role;
import com.sam.dynamic.project.ds1.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Sam
 * @apiNote 消息中心 服务实现类
 * @since 2024-04-15 16:41:17
 */
@Service
public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> implements MessageService {

    @Autowired
    private RoleService roleService;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void transTest() {
        //A库
        Message msg = new Message();
        msg.setId(3L);
        msg.setTitle("自来水缴费清单");
        msg.setLevel(1);
        msg.setContent("尊敬的张三先生，您12月的自来水费用为128.77元，请尽快缴费！");
        super.save(msg);
        //B库
        Role role = new Role();
        role.setId(3L);
        role.setRoleCode("dept");
        role.setRoleName("部门用户");
        role.setSort(1);
        roleService.saveTrans(role);
    }
}
